filters.filter('bigNum', function () {
    return function (input) {
        if (!/^(\d|\.)+$/g.test(input)) {
            return input;
        }

        try {
            input = Number(input);
        } catch (e) {
            return input;
        }

        var num = Number(input.toFixed(0));
        var len = String(num).length;

        if (num < 10000) {
            return num;
        }

        switch (len) {
            case 5:
                return (num / 10000).toFixed(2) + '万';
            case 6:
                return (num / 10000).toFixed(2) + '万';
            case 7:
                return (num / 10000).toFixed(2) + '万';
            case 8:
                return (num / 10000).toFixed(2) + '万';
            case 9:
                return (num / 100000000).toFixed(2) + '亿';
            case 10:
                return (num / 100000000).toFixed(2) + '亿';
            case 11:
                return (num / 100000000).toFixed(2) + '亿';
            case 12:
                return (num / 100000000).toFixed(2) + '亿';
        }

        return num;
    }
});
filters.filter('ymd', function () {
    return function (input) {
        if (/\d{4}-\d{2}-\d{2}/.exec(input)) {
            return /\d{4}-\d{2}-\d{2}/.exec(input)[0];
        }
    }
});
filters.filter('highlight',function($sce){
    "use strict";
    return function (text, phrase) {
        if (phrase) text = text.replace(new RegExp('('+phrase+')', 'gi'),
        '<span class="highlight">$1</span>')

      return $sce.trustAsHtml(text)
        
        /*return a && (b || angular.isNumber(b)) ? 
        (
            a = a.toString(),
            b = b.toString(), 
            c ? a.split(b).join('<span class="highlight">' + b + "</span>") : a.replace(new RegExp(b, "gi"), '<span class="highlight">$&</span>')
        ) : a*/
    }
});
filters.filter('format',function(){
    "use strict";
    return function (a, b) {
        var c = a;
        if (angular.isString(c) && void 0 !== b)
            if (angular.isArray(b) || angular.isObject(b) || (b = [b]), angular.isArray(b)) {
                var d = b.length,
                    e = function (a, c) {
                        return c = parseInt(c, 10), c >= 0 && d > c ? b[c] : a
                    };
                c = c.replace(/\$([0-9]+)/g, e)
            } else angular.forEach(b, function (a, b) {
                c = c.split(":" + b).join(a)
            });
        return c
    }
});